package com.hr.controller;

import com.hr.entity.ConfigFileFirstKind;
import com.hr.entity.R;
import com.hr.mapper.ConfigFileFirstKindMapper;
import com.hr.service.ConfigFileFirstKindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping("/configFileFirstKind")
public class ConfigFileFirstKindController {

    @Autowired
    private ConfigFileFirstKindService configFileFirstKindService;

    /**
     * 查询一级机构
     * @return
     */
    @GetMapping("/queryList")
    public List<ConfigFileFirstKind> queryList(){
        List<ConfigFileFirstKind> list = configFileFirstKindService.queryList();
        System.out.println(list);
        return list;
    }

    /**
     * 保存/修改
     * @param configFileFirstKind
     * @return
     */
    @PostMapping("/save")
    public R save(
            @RequestBody
            ConfigFileFirstKind configFileFirstKind){
                boolean save = configFileFirstKindService.save(configFileFirstKind);
                return save ?R.ok("保存成功"):R.fail("保存失败");
    }

    /**
     * 删除
     * @param ffkid
     * @return
     */
    @DeleteMapping("/del")
    public R del(Integer ffkid){
        boolean del = configFileFirstKindService.del(ffkid);
        return del ? R.ok("删除成功"):R.fail("删除失败");
    }

    /**
     * 单值查询
     * @param ffkid
     * @return
     */
    @GetMapping("/queryById")
    public ConfigFileFirstKind queryById(Integer ffkid){
        ConfigFileFirstKind configFileFirstKind = configFileFirstKindService.queryById(ffkid);
        return configFileFirstKind;
    }
}
